package com.dyna.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.dyna.domain.entity.Items;
import com.dyna.domain.req.ItemPageReq;
import com.dyna.domain.resp.item.ItemPageResp;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @description itemsMapper
 * @author zcw
 * @date 2025-02-27
 */
@Mapper
public interface ItemsMapper extends BaseMapper<Items> {

    /**
     * 分页查询数据
     * @param req req
     * @return List<ItemPageResp>
     */
    List<ItemPageResp> queryPageList(@Param("req") ItemPageReq req);

    /**
     * 删除物品
     * @param itemId 物品id
     * @return Boolean
     */
    @Update("update items set del_flag = 2 where item_id = #{itemId}")
    Boolean del(@Param("itemId") Long itemId);

    @Update("update items set count = count - #{count} where item_id = #{itemId}")
    Boolean reduceCount(@Param("itemId") Long itemId, @Param("count") Long count);
}